#include <gtest/gtest.h>

#include <climits>
#include <cstddef>

#include "queue/priority_queue.h"

class PriorityQueueTest : public ::testing::Test
{
  protected:
    void SetUp() override
    {
        // 初始化代码 (需要时)
    }
};

TEST_F(PriorityQueueTest, MaximumHeapTest)
{
    PriorityQueue<int> queue;
    queue.push(10);
    queue.push(20);
    queue.push(5);
    queue.push(100);

    EXPECT_FALSE(queue.empty());
    EXPECT_EQ(queue.size(), 4);

    EXPECT_EQ(queue.top(), 100);
    queue.pop();
    EXPECT_EQ(queue.top(), 20);
    queue.pop();
    EXPECT_EQ(queue.top(), 10);
    queue.pop();
    EXPECT_EQ(queue.top(), 5);
    queue.pop();

    EXPECT_THROW(queue.top(), std::runtime_error);
    EXPECT_THROW(queue.pop(), std::runtime_error);
}

TEST_F(PriorityQueueTest, MinHeapTest)
{
    PriorityQueue<int, std::greater<int>> queue;
    queue.push(10);
    queue.push(20);
    queue.push(5);
    queue.push(100);

    EXPECT_FALSE(queue.empty());
    EXPECT_EQ(queue.size(), 4);

    EXPECT_EQ(queue.top(), 5);
    queue.pop();
    EXPECT_EQ(queue.top(), 10);
    queue.pop();
    EXPECT_EQ(queue.top(), 20);
    queue.pop();
    EXPECT_EQ(queue.top(), 100);
    queue.pop();

    EXPECT_THROW(queue.top(), std::runtime_error);
    EXPECT_THROW(queue.pop(), std::runtime_error);
}